***Identification Assumption and Robustness Check

clear
eststo clear

*cd "~/Dropbox/Donor Adjustment/Replication/"
use "CombinedData.dta", clear

order WDI_Name id year
xtset id year

gen log_SO2 = log(SO2+1)
label var log_SO2 "log (SO2)"
replace CO2=0 if CO2 < 0
gen log_CO2 = log(CO2+1)
label var log_CO2 "log (CO2)"
gen log_BOD = log(BOD)
label var log_BOD "log (BOD)"
gen log_gdp = log(gdp)
gen log_PM10 = log(pm10)
label var log_PM10 "log (PM10)"
label var log_gdp "log (GDP)" 
gen log_gdp_pc = log(gdp_pc)
label var log_gdp_pc "log (GDP p.c.)"
gen pop = gdp/gdp_pc
gen log_pop = log(pop)
label var log_pop "log (Population)"
label var polity2 "Polity"
label var urban_pop_per "Urban population (\% of total)"
gen time = year-1960
gen time2 = time^2
gen time3 = time^3
gen wto_polity2 = wto * polity2
encode(region), gen(region_id)

gen log_deforest=log(deforest+1)

gen envmin=env_ministry_real
by id (year), sort: replace envmin =. if envmin[_n-1]== 1 
by id (year), sort: replace envmin =. if envmin== 1 & envmin[_n-1]==.

gen FIT1=FIT
by id (year), sort: replace FIT1 =. if FIT1[_n-1]== 1 
by id (year), sort: replace FIT1 =. if FIT1== 1 & FIT1[_n-1]==.
replace FIT1=1 if id==72 & year==1990

egen PTA = rowtotal(USPTA JapanPTA EFTAPTA EUPTA)

      ** Generating 5-Year Forward GATT/WTO
	   xtset id year
	   gen F5GATTWTO=F5.gatt_wto
	   label var F5GATTWTO "Placebo GATT/WTO (5-Year Lead)"
	   gen F3GATTWTO=F3.gatt_wto
	   label var F3GATTWTO "Placebo GATT/WTO (3-Year Lead)"
	   gen F7GATTWTO=F7.gatt_wto
	   label var F7GATTWTO "Placebo GATT/WTO (7-Year Lead)" 
	   gen F10GATTWTO=F10.gatt_wto
	   label var F10GATTWTO "Placebo GATT/WTO (10-Year Lead)"  
	   
	   replace F5GATTWTO=L.F5GATTWTO if F5GATTWTO ==. & year > 2005
	   replace F3GATTWTO=L.F3GATTWTO if F3GATTWTO ==. & year > 2007
	   replace F7GATTWTO=L.F7GATTWTO if F7GATTWTO ==. & year > 2003
   	   replace F10GATTWTO=L.F10GATTWTO if F10GATTWTO ==. & year > 2000
	   
	   gen F5WTO=F5.wto
	   label var F5WTO "Placebo WTO (5-Year Lead)"
	   gen F3WTO=F3.wto
	   label var F3WTO "Placebo WTO (3-Year Lead)"
	   gen F7WTO=F7.wto
	   label var F7WTO "Placebo WTO (7-Year Lead)"
	   gen F10WTO=F10.wto
	   label var F10WTO "Placebo WTO (10-Year Lead)"
	   
	   replace F5WTO=L.F5WTO if F5WTO ==. & year > 2005
	   replace F3WTO=L.F3WTO if F3WTO ==. & year > 2007
	   replace F7WTO=L.F5WTO if F7WTO ==. & year > 2003
	   replace F10WTO=L.F3WTO if F10WTO ==. & year > 2000
	   
	   
*cd "~/Dropbox/Donor Adjustment/Replication/check"


*Table A23: Pre-GATT/WTO Membership Data Only (3 year lead)
		eststo clear
	  	eststo: xi: xtreg log_SO2 F3GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if gatt_wto==0, robust
		eststo: xi: xtreg log_CO2 F3GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if gatt_wto==0, robust
		eststo: xi: xtreg log_BOD F3GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if gatt_wto==0, robust
		eststo: xi: xtreg electricity_coal_production F3GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if gatt_wto==0, robust
		eststo: xi: xtreg electricity_production_renew F3GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if gatt_wto==0, robust
	  
		*esttab using "PreGATTWTOOnly1_3Year.tex", booktabs label title(Pre-GATT/WTO Membership Data Only \label{gattwto3lead}) keep (F3GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per) order (F3GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per)  mtitles ("SO2" "CO2" "BOD" "Coal" "Renew.")  stats(N_g N, labels(Countries Observations) fmt(0 0)) indicate("Country FE=_Iid_*" "Year FE=_Iyear_*" ) nodepvars se(3) b(3) replace star(* 0.10 ** 0.05 *** 0.01) compress nogaps
	
*Table A24: Pre-GATT/WTO Membership Data Only (5 year lead)
		eststo clear
	  	eststo: xi: xtreg log_SO2 F5GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if gatt_wto==0, robust
		eststo: xi: xtreg log_CO2 F5GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if gatt_wto==0, robust
		eststo: xi: xtreg log_BOD F5GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if gatt_wto==0, robust
		eststo: xi: xtreg electricity_coal_production F5GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if gatt_wto==0, robust
		eststo: xi: xtreg electricity_production_renew F5GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if gatt_wto==0, robust
	  
		*esttab using "PreGATTWTOOnly1_5Year.tex", booktabs label title(Pre-GATT/WTO Membership Data Only \label{gattwto5lead}) keep (F5GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per) order (F5GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per)  mtitles ("SO2" "CO2" "BOD" "Coal" "Renew.")  stats(N_g N, labels(Countries Observations) fmt(0 0)) indicate("Country FE=_Iid_*" "Year FE=_Iyear_*" ) nodepvars se(3) b(3) replace star(* 0.10 ** 0.05 *** 0.01) compress nogaps

*Table A25: Pre-GATT/WTO Membership Data Only (7 year lead) 
		eststo clear
	  	eststo: xi: xtreg log_SO2 F7GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if gatt_wto==0, robust
		eststo: xi: xtreg log_CO2 F7GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if gatt_wto==0, robust
		eststo: xi: xtreg log_BOD F7GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if gatt_wto==0, robust
		eststo: xi: xtreg electricity_coal_production F7GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if gatt_wto==0, robust
		eststo: xi: xtreg electricity_production_renew F7GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if gatt_wto==0, robust
	  
		*esttab using "PreGATTWTOOnly1_7Year.tex", booktabs label title(Pre-GATT/WTO Membership Data Only \label{gattwto7lead}) keep (F7GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per) order (F7GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per)  mtitles ("SO2" "CO2" "BOD" "Coal" "Renew.")  stats(N_g N, labels(Countries Observations) fmt(0 0)) indicate("Country FE=_Iid_*" "Year FE=_Iyear_*" ) nodepvars se(3) b(3) replace star(* 0.10 ** 0.05 *** 0.01) compress nogaps

*Table A26: Pre-GATT/WTO Membership Data Only (10 year lead)
		eststo clear
	  	eststo: xi: xtreg log_SO2 F10GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if gatt_wto==0, robust
		eststo: xi: xtreg log_CO2 F10GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if gatt_wto==0, robust
		eststo: xi: xtreg log_BOD F10GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if gatt_wto==0, robust
		eststo: xi: xtreg electricity_coal_production F10GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if gatt_wto==0, robust
		eststo: xi: xtreg electricity_production_renew F10GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if gatt_wto==0, robust
	  
		*esttab using "PreGATTWTOOnly1_10Year.tex", booktabs label title(Pre-GATT/WTO Membership Data Only \label{gattwto10lead}) keep (F10GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per) order (F10GATTWTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per)  mtitles ("SO2" "CO2" "BOD" "Coal" "Renew.")  stats(N_g N, labels(Countries Observations) fmt(0 0)) indicate("Country FE=_Iid_*" "Year FE=_Iyear_*" ) nodepvars se(3) b(3) replace star(* 0.10 ** 0.05 *** 0.01) compress nogaps


*Table A27: Pre-WTO Membership Data Only (3 year lead) 
		eststo clear
	  	eststo: xi: xtreg log_SO2 F3WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if wto==0 & year>= 1990, robust
		eststo: xi: xtreg log_CO2 F3WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if wto==0 & year>= 1990, robust
		eststo: xi: xtreg log_BOD F3WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if wto==0 & year>= 1990, robust
		eststo: xi: xtreg electricity_coal_production F3WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if wto==0 & year>= 1990, robust
		eststo: xi: xtreg electricity_production_renew F3WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if wto==0 & year>= 1990, robust

		*esttab using "PreGATTWTOOnly2_3Year.tex", booktabs label title(Pre-WTO Membership Data Only \label{wto3lead}) keep (F3WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per) order (F3WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per)  mtitles ("SO2" "CO2" "BOD" "Coal" "Renew.")  stats(N_g N, labels(Countries Observations) fmt(0 0)) indicate("Country FE=_Iid_*" "Year FE=_Iyear_*" ) nodepvars se(3) b(3) replace star(* 0.10 ** 0.05 *** 0.01) compress nogaps

		
*Table A28: Pre-WTO Membership Data Only (5 year lead)
		eststo clear
	  	eststo: xi: xtreg log_SO2 F5WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if wto==0 & year>= 1990 , robust
		eststo: xi: xtreg log_CO2 F5WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if wto==0 & year>= 1990, robust
		eststo: xi: xtreg log_BOD F5WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if wto==0 & year>= 1990, robust
		eststo: xi: xtreg electricity_coal_production F5WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if wto==0 & year>= 1990, robust
		eststo: xi: xtreg electricity_production_renew F5WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if wto==0 & year>= 1990, robust

		*esttab using "PreGATTWTOOnly2_5Year.tex", booktabs label title(Pre-WTO Membership Data Only \label{wto5lead}) keep (F5WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per) order (F5WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per)  mtitles ("SO2" "CO2" "BOD" "Coal" "Renew.")  stats(N_g N, labels(Countries Observations) fmt(0 0)) indicate("Country FE=_Iid_*" "Year FE=_Iyear_*" ) nodepvars se(3) b(3) replace star(* 0.10 ** 0.05 *** 0.01) compress nogaps

*Table A29: Pre-WTO Membership Data Only (7 year lead)
		eststo clear
	  	eststo: xi: xtreg log_SO2 F7WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if wto==0 & year>= 1990, robust
		eststo: xi: xtreg log_CO2 F7WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if wto==0 & year>= 1990, robust
		eststo: xi: xtreg log_BOD F7WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if wto==0 & year>= 1990, robust
	  	eststo: xi: xtreg electricity_coal_production F7WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if wto==0 & year>= 1990, robust
		eststo: xi: xtreg electricity_production_renew F7WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if wto==0 & year>= 1990, robust

		*esttab using "PreGATTWTOOnly2_7Year.tex", booktabs label title(Pre-WTO Membership Data Only \label{wto7lead}) keep (F7WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per) order (F7WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per)  mtitles ("SO2" "CO2" "BOD" "Coal" "Renew.")  stats(N_g N, labels(Countries Observations) fmt(0 0)) indicate("Country FE=_Iid_*" "Year FE=_Iyear_*" ) nodepvars se(3) b(3) replace star(* 0.10 ** 0.05 *** 0.01) compress nogaps

		
*Table A30: Pre-WTO Membership Data Only (10 year lead)
		eststo clear
	  	eststo: xi: xtreg log_SO2 F10WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if wto==0 & year>= 1990, robust
		eststo: xi: xtreg log_CO2 F10WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if wto==0 & year>= 1990, robust
		eststo: xi: xtreg log_BOD F10WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if wto==0 & year>= 1990, robust
		eststo: xi: xtreg electricity_coal_production F10WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if wto==0 & year>= 1990, robust
		eststo: xi: xtreg electricity_production_renew F10WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year i.id if wto==0 & year>= 1990, robust

		*esttab using "PreGATTWTOOnly2_10Year.tex", booktabs label title(Pre-WTO Membership Data Only \label{wto10lead}) keep (F10WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per) order (F10WTO polity2 log_gdp_pc log_pop life_expectancy urban_pop_per)  mtitles ("SO2" "CO2" "BOD" "Coal" "Renew.")  stats(N_g N, labels(Countries Observations) fmt(0 0)) indicate("Country FE=_Iid_*" "Year FE=_Iyear_*" ) nodepvars se(3) b(3) replace star(* 0.10 ** 0.05 *** 0.01) compress nogaps

*************************************		
*Country-Specific Time Trend Included:
*************************************

	    ** Generating State Dummies / State-Specific Trends
	  
		tabulate id, gen (state)
		
		forvalues i = 1(1)214 {
		generate statetrend`i' = state`i' * time
		}
		
		forvalues i = 1(1)214 {
		generate statetrend_sq`i' = state`i' * time2
		}
		
		forvalues i = 1(1)214 {
		generate statetrend_cube`i' = state`i' * time3
		}

*Table A31: Country-Specific Time Trend Included: GATT/WTO
		eststo clear
	  	eststo: xi: xtreg log_SO2 gatt_wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year statetrend1 - statetrend214, fe robust
		eststo: xi: xtreg log_CO2 gatt_wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year statetrend1 - statetrend214, fe robust
		eststo: xi: xtreg log_BOD gatt_wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year statetrend1 - statetrend214, fe robust
		eststo: xi: xtreg electricity_coal_production gatt_wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year statetrend1 - statetrend214, fe robust
		eststo: xi: xtreg electricity_production_renew gatt_wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year statetrend1 - statetrend214, fe robust
	    
		*esttab using "StateSpecificTrend1.tex", booktabs label title(State-Specific Time Trend Included \label{trend1}) keep (gatt_wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per) order (gatt_wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per)  mtitles ("SO2" "CO2" "BOD" "Coal" "Renew." "Env. Aid" "Harm. Aid")  stats(N_g N, labels(Countries Observations) fmt(0 0)) indicate("Year FE=_Iyear_*" ) nodepvars se(3) b(3) replace star(* 0.10 ** 0.05 *** 0.01) compress nogaps

*Table A32: Country-Specific Time Trend Included: GATT/WTO 
		eststo clear
	  	eststo: xi: xtreg log_SO2 wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year statetrend1 - statetrend214 if year>=1995, fe robust
		eststo: xi: xtreg log_CO2 wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year statetrend1 - statetrend214 if year>=1995, fe robust
		eststo: xi: xtreg log_BOD wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year statetrend1 - statetrend214 if year>=1995, fe robust
		eststo: xi: xtreg electricity_coal_production wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year statetrend1 - statetrend214 if year>=1995, fe robust
		eststo: xi: xtreg electricity_production_renew wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year statetrend1 - statetrend214 if year>=1995, fe robust
	    
		*esttab using "StateSpecificTrend2.tex", booktabs label title(State-Specific Time Trend Included \label{trend1}) keep (wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per) order (wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per)  mtitles ("SO2" "CO2" "BOD" "Coal" "Renew." "Env. Aid" "Harm. Aid")  stats(N_g N, labels(Countries Observations) fmt(0 0)) indicate("Year FE=_Iyear_*" ) nodepvars se(3) b(3) replace star(* 0.10 ** 0.05 *** 0.01) compress nogaps

